<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>原生JS控制DOM显示隐藏</title>
</head>
<body>
    <button onclick="toggleElement()">切换显示/隐藏</button>
    <div id="myElement" style="width: 100px; height: 100px; background-color: red;">
        这是一个DOM元素
    </div>
    <div>
        fkdsajklfajfsadjkfljdskalfjdsl
    </div>

    <script>
        function toggleElement() {
            var element = document.getElementById("myElement");
            if (element.style.display === "none") {
                element.style.display = "block";
            } else {
                element.style.display = "none";
            }
        }
    </script>
</body>
</html>
